package com.bbex.mapper;

import com.bbex.entity.PhoneGeocoder;
import com.bbex.sql.build.PhoneGeocoderBuild;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;

@Mapper
public interface PhoneGeocoderDao {

    @Select("select " + PhoneGeocoder.columns + " from js_plat_phone_geocoder where user_id = #{user_id}")
    PhoneGeocoder findByUserId(String userId);

    @InsertProvider(type = PhoneGeocoderBuild.class, method = "insert")
    void insert(PhoneGeocoder phoneGeocoder);

    @Select("SELECT IFNULL(COUNT(1), 0) FROM js_plat_phone_geocoder t WHERE t.city_id = #{cityId} AND t.create_date > #{beginDate}")
    long countByAreaId(@Param("cityId") String cityId, @Param("beginDate") LocalDateTime beginDate);
}
